This is an example of twisted abuse of user interface in order to achieve a noble purpose.
Several developers have written in saying, "I want to select folders." We've got a couple of samples written which show folder selection. You basically add a file filter which ignores files to CustomGetFile(). Developers don't like these samples, because the files don't show up in gray, and some users get confused by only having a folder name at the top of the dialog.
This behavior (no file names) is a limitation of CustomGetFile. Your filter told it not to display file names, so it doesn't. There aren't any easy changes you can make by patching Standard File -- about the only thing StandardFile does is check for the trash and gray it out, using internal information only known to the Standard File package.
Well, CustomPutFile() does show the grayed out files. So... we use CustomPutFile to emulate CustomGetFile. Yes, that's "Put", as in "put him out of his misery..."
I took the standard Put file dialog and modified it slightly. I changed the name and location of the first button (normally, the save button). I moved two items (the prompt and default name) off the screen. I pass in an activation list, so that only the file/folder list gets keyboard input.
CustomPutFile doesn't return the FSSpec you want, since it builds one from the name you've passed in plus the parID and vRefNum. So you have to call FSMakeFSSpec() with the parID and vRefNum that CustomPutFile hands you. Now you have the real FSSpec for the directory your user wants.
I haven't gotten rid of the New Folder button. You probably should.
I've also included a complicated example of using CustomGetFile to select folders.
The basic code comes from C.K. Haun's simple sample on the developer CD.
--Brian Bechtel, DTS, October 5, 1993
MODIFICATIONS
•Added a couple of routines from the MoreFiles sample to get information about the Owner and Group of a directory.
•Instead of reporting the vRefNum and the parID in a dialog, I report the Owner Name and Group Name of the directory.
(Please note: This requires Think C version 7.0.x or MPW 3.3.x.)